﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Apriori
{
    /// <summary>
    /// Stores all data related with Products and pointners for building t-tree.
    /// </summary>
    class Product
    {
        private Itemset children;
        private Product parent;
        private string name;
        private int index;
        private double prevelance;
        private int count;
        private int cardcounter;

        public Product()
        {
            this.children = null;
            this.parent = null;
            this.name = "";
            this.index = -1;
            this.prevelance = -1;
            this.count = -1;
            this.cardcounter = -1;
        }

        public Product(Itemset next, Product previous, string n, int i, double p, int c, int cardinality)
        {
            this.children = next;
            this.parent = previous;
            this.name = n;
            this.index = i;
            this.prevelance = p;
            this.count = c;
            this.cardcounter = cardinality;
        }

        public int Cardinality
        {
            get { return this.cardcounter; }
            set { this.cardcounter = value; }
        }

        public Product Previous
        {
            get { return this.parent; }
            set { this.parent = value; }
        }

        public Itemset Next
        {
            get { return children; }
            set { children = value; }
        }

        public void SetCount(int c)
        {
            this.count = c;
        }

        public int GetCount()
        {
            return this.count;
        }

        public void SetPrevelance(double p)
        {
            this.prevelance = p;
        }

        public double Prevelance
        {
            get { return prevelance; }
            set { prevelance = value; }
        }

        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        public int Count
        {
            get { return count; }
            set { count = value; }
        }

        public int Index
        {
            get { return index; }
            set { index = value; }
        }

        public double GetPrevelance()
        {
            return this.prevelance;
        }

        public override string  ToString()
        {
            return this.name;
        }
    }
}
